//
//  ShellWallertCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/9/27.
//  Copyright © 2019年 VV. All rights reserved.
//

#import "ShellWallertCell.h"
#import "ShellWallertModel.h"


@interface ShellWallertCell()

//数量
@property (nonatomic,strong) UILabel *numberLabel;

//类型
@property (nonatomic,strong) UILabel *typeLabel;

//状态
@property (nonatomic,strong) UILabel *statusLabel;

//时间
@property (nonatomic,strong) UILabel *timeLabel;

@end

@implementation ShellWallertCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{
    
    //数量
    [self.contentView addSubview:self.numberLabel];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(self.contentView);
    }];
    
    //类型
    [self.contentView addSubview:self.typeLabel];
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.numberLabel.mas_right).mas_offset(10);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(40);
    }];
    
    
    //状态
    [self.contentView addSubview:self.statusLabel];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.typeLabel.mas_right).mas_offset(5);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(self.contentView);
    }];
    
    
    //时间
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.statusLabel.mas_right).mas_offset(10);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(self.contentView);
    }];
    
}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellWallertModel *wallertModel = modelObject;
    self.numberLabel.textColor = UIColorHex(0xF4376D);
    if(self.indexPath.row % 2 == 0){
        self.backgroundColor = COLOR_BACKGROUND;
    } else {
        self.backgroundColor = UIColorHex(0x031D32);
    }
    
    NSString *operateAmount = [NSString stringWithFormat:@"%@",wallertModel.operateAmount].scientific;
    NSString *add = @"-";

    if([wallertModel.busiCode isEqualToString:@"charge"]){
        self.typeLabel.text = LZLocalizedString(@"充值");
        self.numberLabel.textColor = UIColorHex(0x80C35F);
        add = @"+";
    } else if ([wallertModel.busiCode isEqualToString:@"withdraw"]){
        self.typeLabel.text = LZLocalizedString(@"提币");
    } else if ([wallertModel.busiCode isEqualToString:@"settle"]){
        self.typeLabel.text = LZLocalizedString(@"清算");
    } else if ([wallertModel.busiCode isEqualToString:@"pledge"]){
        self.typeLabel.text = LZLocalizedString(@"质押");
    } else if ([wallertModel.busiCode isEqualToString:@"order"]){
        self.typeLabel.text = LZLocalizedString(@"订单");
        self.numberLabel.textColor = UIColorHex(0x80C35F);
        add = @"+";
    } else if ([wallertModel.busiCode isEqualToString:@"reward"]){
        self.typeLabel.text = LZLocalizedString(@"奖励");
        self.numberLabel.textColor = UIColorHex(0x80C35F);
        add = @"+";
    } else if ([wallertModel.busiCode isEqualToString:@"minePool"]){
        self.typeLabel.text = LZLocalizedString(@"矿池");
        self.numberLabel.textColor = UIColorHex(0x80C35F);
        add = @"+";
    }  else if ([wallertModel.busiCode isEqualToString:@"buyCrowd"]){
        self.typeLabel.text = LZLocalizedString(@"预约配售");
    } else if ([wallertModel.busiCode isEqualToString:@"exchangeOut"]){
        self.typeLabel.text = LZLocalizedString(@"闪兑");
    }


    NSInteger status = [wallertModel.status integerValue];
    switch (status) {
        case 10:
            self.statusLabel.text = LZLocalizedString(@"待处理");
            break;
        case 20:
            self.statusLabel.text = LZLocalizedString(@"待处理");
            break;
        case 21:
            self.statusLabel.text = LZLocalizedString(@"区块确认中");
            break;
        case 30:
            self.statusLabel.text = LZLocalizedString(@"成功");
            break;
        case 40:
            self.statusLabel.text = LZLocalizedString(@"失败");
            break;
        default:
            break;
    }
    
    self.numberLabel.text = [NSString stringWithFormat:@"%@%@",add,operateAmount];
    self.timeLabel.text = wallertModel.createTime;
}


//货币
- (UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _numberLabel;
}

//类型
- (UILabel *)typeLabel{
    if(!_typeLabel){
        _typeLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
        _typeLabel.numberOfLines = 0;
        _typeLabel.adjustsFontSizeToFitWidth = YES;
    }
    return _typeLabel;
}

//状态
- (UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _statusLabel;
}

//时间
- (UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0x678DA8) font:k_textFont(13)];
        [_timeLabel lz_rightAlignment];
    }
    return _timeLabel;
}



@end
